package provider;

import anaydis.sort.Sorter;
import anaydis.sort.SorterType;
import anaydis.sort.provider.SorterProvider;
import impl.*;
import impl.QuickSorter;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
import java.util.Map;


public class SorterPorviderImpl implements SorterProvider {


    private Map<SorterType, Sorter> map;

    public SorterPorviderImpl() {
        map = new EnumMap<SorterType,Sorter>(SorterType.class);

        map.put(SorterType.QUICK,new QuickSorter());
        map.put(SorterType.H,new HSorter());
        map.put(SorterType.QUICK,new QuickSorter());
        map.put(SorterType.QUICK_CUT,new QuickSortWithCut());
        map.put(SorterType.BUBBLE,new BubbleSorter());
        map.put(SorterType.INSERTION,new InsertionSorter());
        map.put(SorterType.SHELL,new ShellSorter());
        map.put(SorterType.QUICK_NON_RECURSIVE,new QuickSortNonRecursive());
        map.put(SorterType.SELECTION,new SelectionSorter());
        map.put(SorterType.MERGE_BOTTOM_UP,new MergeSorterBottonUp());
        map.put(SorterType.MERGE,new MergeSorterTopDown());
    }


    @NotNull
    public Sorter getSorterForType(@NotNull SorterType sorterType) {
        return map.get(sorterType);
    }

    @NotNull
    public Iterable<Sorter> getAllSorters() {
        return map.values();
    }
}
